#include <stdio.h>
#include <string.h>
#include <ctype.h>

/**
 * 确定字符串和字符信息及使用printf
 */
int main() {

	char cc, long_string[50], many_lines[70];
	int occupied, reserved, buffer_size;

	printf("******* Section 1 - conversion specifications ******\n");
	strcpy(long_string, "This is a complete sentence.");
	strcpy(many_lines, "This sentence \ncovers two lines.");
	printf("[[%s]]\n", long_string);
	printf("[[%40s]]\n", long_string);
	printf("[[%-40s]]\n", long_string);
	printf("[[%40.10s]]\n", long_string);

	printf("\n ******* Section 2 - finding information about strings ***\n");
	// strlen 函数获取字符串有多少个字符
	occupied = strlen(many_lines);
	// sizeof 计算指定的变量或变量类型所占用的内存字节数
	reserved = sizeof many_lines / sizeof(char);
	// 表示stdio一次能传输的最大字符数目
	buffer_size = BUFSIZ;
	printf("occupied = %d, reserved = %d, buffer_size = %d\n",
		   occupied, reserved, buffer_size);

	// isdigit 函数判断字符是否是数字
	if (isdigit('1')) {
		putchar('1');
		putchar('\n');
	}


	cc = tolower(many_lines[0]);
	putchar(cc);
	putchar('\n');
	puts(many_lines);

}